import request from '@/utils/request'

// 查询采购订单列表
export function listOrder(query) {
    return request({
        url: '/purchase/order/list',
        method: 'get',
        params: query
    })
}

// 查询采购订单详细
export function getOrder(id) {
    return request({
        url: '/purchase/order/' + id,
        method: 'get'
    })
}

// 新增采购订单
export function addOrder(data) {
    return request({
        url: '/purchase/order',
        method: 'post',
        data: data
    })
}

// 修改采购订单
export function updateOrder(data) {
    return request({
        url: '/purchase/order',
        method: 'put',
        data: data
    })
}

// 删除采购订单
export function delOrder(id) {
    return request({
        url: '/purchase/order/' + id,
        method: 'delete'
    })
}

// 获取订单编号
export function getCGDD(){
    return request({
        url: '/purchase/order/getCGDD',
        method: 'get'
    })
}

// 修改状态
export function changeOrderStatus(id,status) {
    const data = {
        id,
        status
    }
    return request({
        url: '/purchase/order/changeStatus',
        method: 'put',
        data: data
    })
}

// 查询采购订单物料清单列表
export function listMaterial(query) {
    return request({
        url: '/purchase/orderMaterial/list',
        method: 'get',
        params: query
    })
}

// 查询采购订单物料清单详细
export function getMaterial(id) {
    return request({
        url: '/purchase/orderMaterial/' + id,
        method: 'get'
    })
}

// 新增采购订单物料清单
export function addMaterial(data) {
    return request({
        url: '/purchase/orderMaterial',
        method: 'post',
        data: data
    })
}

// 修改采购订单物料清单
export function updateMaterial(data) {
    return request({
        url: '/purchase/orderMaterial',
        method: 'put',
        data: data
    })
}

// 删除采购订单物料清单
export function delMaterial(id) {
    return request({
        url: '/purchase/orderMaterial/' + id,
        method: 'delete'
    })
}